package com.fqgj.xjd.user.config;

import com.alibaba.nacos.api.config.annotation.NacosValue;
import org.springframework.stereotype.Component;

/**
 * User: zhangxingyun
 * Date: 2017-07-20
 * Time: 18:38:52.910
 */
@Component
public class ConfigUtil {

    @NacosValue(value = "${server.test}", autoRefreshed = true)
    private boolean serverTest;

    @NacosValue(value = "${oss.qsyq.bucketName:\"\"", autoRefreshed = true)
    private String ossBuckName;

    @NacosValue(value = "${oss.qsyq.base.url:\"\"", autoRefreshed = true)
    private String qsyqBaseUr;

    @NacosValue(value = "${mock.bind.card:true}", autoRefreshed = true)
    private boolean isMockBindCard;

    @NacosValue(value = "${promotion.channel:meetsocial,sojoy,miqtech,mobvista", autoRefreshed = true)
    private String promotionChannel;

    public boolean isServerTest() {
        return serverTest;
    }

    public String getBucketName() {
        return ossBuckName;
    }

    public String getQsyqBaseUrl() {
        return qsyqBaseUr;
    }

    public boolean isMockBindCard() {
        return isMockBindCard;
    }

    public boolean isNotOrganicChannel(String channel) {
        String promotionChannelStr = promotionChannel;
        String[] promotionChannelArr = promotionChannelStr.split(",");
        for (String promotionChannel : promotionChannelArr) {
            if (channel.toLowerCase().contains(promotionChannel)) {
                return true;
            }
        }
        return false;
    }

}
